home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / ov143b.zip / OVFDISP.C < prev    next >
C/C++ Source or Header  |  1993-01-04  |  9KB  |  276 lines

  1. /*  028  8-Jun-87  ovfdisp.c
  2.  
  3.         Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
  4. */
  5.  
  6. #include "ov.h"
  7. #include "direct.h"
  8.  
  9. #define V_bar (0xba)
  10. #define H_bar (0xcd)
  11.  
  12. #define INFO_COLS (60)                 /* extra file info uses 60 xtra cols */
  13.  
  14. extern WINDOW cw;
  15. extern FILE_ENT files[];
  16. extern unsigned char help_display;     /* NZ if help is active   */
  17.  
  18. char *mmddyy();
  19. unsigned long alloc_siz(unsigned long, unsigned int);
  20.  
  21.  
  22. /******************************************************************************
  23.  **                   S E T U P _ F I L E _ S C R                            **
  24.  *****************************************************************************/
  25.  
  26. setup_file_scr() {     /* setup the static file display screen image */
  27.  
  28.    setvattrib(DIS_NORM);               /* incase vid attribs just changed */
  29.  
  30.    clr_scr();                          /* start off with clear screen */
  31.  
  32.    setvattrib(DIS_TEXT);
  33.  
  34.    disp_str_at("\xc9\xcd Volume \xcd\xcd\xcb\xcd Path ",VOL_ROW-1,0);
  35.    disp_rep(H_bar,SCREEN_COLS-21);
  36.    disp_char_at(0xbb,VOL_ROW-1,SCREEN_COLS-1);
  37.  
  38.    disp_char_at(V_bar,VOL_ROW,0);
  39.    disp_char_at(V_bar,VOL_ROW,PATH_COL-1);
  40.    disp_char_at(V_bar,VOL_ROW,SCREEN_COLS-1);
  41.  
  42.    disp_char_at(V_bar,VOL_ROW+1,0);
  43.    disp_rep(' ',PATH_COL-2);
  44.    disp_char_at(0xc8,VOL_ROW+1,PATH_COL-1);
  45.    disp_rep(H_bar,SCREEN_COLS-14);
  46.    disp_str_at("\xcb\xcd Files ",VOL_ROW+1,19);
  47.    disp_char_at(0xb9,VOL_ROW+1,SCREEN_COLS-1);
  48.    disp_str_at("\xcb\xcd Selection ",VOL_ROW+1,61);
  49.  
  50.    disp_str_at("\xba            TOTAL \xba SELECTED:       FILES             BYTES \xba MASK:",
  51.       FILE_STAT_ROW,0);
  52.    disp_char_at(V_bar,FILE_STAT_ROW,SCREEN_COLS-1);
  53.    disp_str_at("\xba            FREE  \xba TAGGED:         FILES             BYTES \xba ATRS:",
  54.       TAG_STAT_ROW,0);
  55.    disp_char_at(V_bar,TAG_STAT_ROW,SCREEN_COLS-1);
  56.  
  57.    disp_char_at(0xc8,UP_BOUND,0);
  58.    disp_rep(H_bar,SCREEN_COLS-2);
  59.    disp_char_at(0xca,UP_BOUND,19);
  60.    disp_char_at(0xca,UP_BOUND,61);
  61.    disp_char_at(0xbc,UP_BOUND,SCREEN_COLS-1);
  62.  
  63.    disp_status();              /* display the status line - resets vid attrib */
  64. }
  65.  
  66.  
  67. /******************************************************************************
  68.  **                        D I S P _ F I L E                                 **
  69.  *****************************************************************************/
  70.  
  71. #pragma check_stack-
  72.  
  73. void ALTCALL
  74. disp_file(fp,is_cur)   /* display one file name with approiate video attrib */
  75. register struct file_ent *fp;
  76. int is_cur;
  77. {
  78.    register int fast;
  79.    int fillsiz, i, is_pm, fnlen, va;
  80.  
  81.    /* set the video attribute to use */
  82.  
  83.    va = is_cur ? DIS_HIGH : (fp->flags & TAGGED ? DIS_TAGD : DIS_NORM);
  84.    if (va != DIS_NORM)
  85.       setvattrib(va);
  86.  
  87.    if (fnlen = strlen(fp->name)) {
  88.       disp_str(fp->flags & TAGGED ? "\x1A " : "  ");   /* tagged flag gets -> */
  89.       disp_str(fp->name);                              /* display the name */
  90.       if (fp->flags & DIR) {                           /* \ after dir names */
  91.          disp_char('\\');
  92.          fnlen++;
  93.       }
  94.    }
  95.  
  96.    disp_rep(' ',cw.maxlen - fnlen);    /* blank fill the name field */
  97.  
  98.    /* display extended file info if active */
  99.  
  100.    if (cw.info_display && fnlen) {
  101.  
  102.       out_long(fp->size,10,' ');       /* display used/allocated sizes */
  103.       out_long(alloc_siz(fp->size,cw.drivep->clustersiz),11,' ');
  104.  
  105.       disp_str("   ");                 /* 3 blanks before date */
  106.       disp_str(mmddyy(fp->date));
  107.  
  108.       disp_str("   ");                 /* 3 blanks before time */
  109.  
  110.       i = ((fast = fp->time) & 0xF800) >> 11;  /* i = hours */
  111.  
  112.       if (is_pm = (i > 12))            /* is it AM or PM? */
  113.          i -= 12;
  114.  
  115.       out_int(i,2,' ');                /* out go the hours */
  116.       disp_char(':');
  117.  
  118.       out_int((fast & 0x07E0) >> 5,2,'0');     /* now the minutes */
  119.       disp_char(':');
  120.  
  121.       out_int((fast & 0x1F) << 1,2,'0');       /* seconds */
  122.  
  123.       disp_str(is_pm ? " pm  " : " am  ");
  124.  
  125.       disp_attrib(fp->flags);          /* display the R H S A attributes */
  126.  
  127.       disp_str(fp->flags & DIR ? " DIR" : "    ");   /* do the DIR attrib */
  128.  
  129.       fillsiz = cw.colsiz - cw.maxlen - INFO_COLS - 2;
  130.  
  131.    } else              /* no extended file info display */
  132.  
  133.       fillsiz = cw.colsiz - cw.maxlen - 2;
  134.  
  135.    disp_rep(' ',fillsiz);              /* blank fill the column */
  136.  
  137.    if (va != DIS_NORM)                 /* restore video attrib if not normal */
  138.       setvattrib(DIS_NORM);
  139. }
  140. #pragma check_stack+
  141.  
  142.  
  143. /******************************************************************************
  144.  **                      D I S P _ A T T R I B                               **
  145.  *****************************************************************************/
  146.  
  147. #pragma check_stack-
  148.  
  149. disp_attrib(attribs)   /* display the attributes in R H S A format */
  150. register int attribs;
  151. {
  152.    static char *no_at = " .";
  153.  
  154.    disp_str(attribs & RDONLY  ? " R" : no_at);
  155.    disp_str(attribs & HIDDEN  ? " H" : no_at);
  156.    disp_str(attribs & SYSTEM  ? " S" : no_at);
  157.    disp_str(attribs & ARCHIVE ? " A" : no_at);
  158. }
  159. #pragma check_stack+
  160.  
  161. /******************************************************************************
  162.  **                    D I S P _ V O L _ S T A T S                           **
  163.  *****************************************************************************/
  164.  
  165. void ALTCALL
  166. disp_vol_stats() {
  167.  
  168.    gotorc(FILE_STAT_ROW,VOL_STAT_COL);
  169.    out_long(cw.drivep->vol_size,10,' ');
  170.    gotorc(TAG_STAT_ROW,VOL_STAT_COL);
  171.    out_long(cw.drivep->vol_free,10,' ');
  172. }
  173.  
  174.  
  175. /******************************************************************************
  176.  **                  D I S P _ F I L E _ S T A T S                           **
  177.  *****************************************************************************/
  178.  
  179. void ALTCALL
  180. disp_file_stats() {
  181.  
  182.    gotorc(FILE_STAT_ROW,NUM_FILES_COL);
  183.    out_int(cw.num_files,5,' ');
  184.    gotorc(FILE_STAT_ROW,SPACE_USED_COL);
  185.    out_long(cw.files_size,10,' ');
  186.    gotorc(TAG_STAT_ROW,NUM_FILES_COL);
  187.    out_int(cw.num_tagged,5,' ');
  188.    gotorc(TAG_STAT_ROW,SPACE_USED_COL);
  189.    out_long(cw.tag_size,10,' ');
  190. }
  191.  
  192.  
  193. /*****************************************************************************
  194.                            D I S P _ P A T H
  195.  *****************************************************************************/
  196.  
  197. disp_path(idx)         /* display a files dir path - only used in showall */
  198. int idx;
  199. {
  200.    gotorc(VOL_ROW,PATH_COL+1);         /* display the files pathname */
  201.    out_str(files[idx].dirp,65,' ');
  202. }
  203.  
  204.  
  205. /******************************************************************************
  206.                            D I S P _ S T A T U S
  207.  *****************************************************************************/
  208.  
  209. disp_status() {        /* display the status line */
  210.  
  211.    setvattrib(DIS_HEAD);
  212.    disp_rep_at(' ',SCREEN_COLS,STATUS_ROW,0);
  213.  
  214.    if (!help_display) {
  215.       disp_str_at(" Press F1 for Help ",STATUS_ROW,SCREEN_COLS/2-10);
  216.       disp_str_at("verify ",STATUS_ROW,SCREEN_COLS-12);
  217.       disp_str(getverify() ? "ON" : "OFF");
  218.    }
  219.  
  220.    setvattrib(DIS_NORM);
  221. }
  222.  
  223.  
  224. /******************************************************************************
  225.                         D I S P / C L R _ M S G
  226.  *****************************************************************************/
  227.  
  228. #define MSGLEN 25
  229.  
  230. disp_msg(cnt,m1)       /* display msg strings on the status line */
  231. int cnt;
  232. char *m1;
  233. {
  234.    int len = 0;
  235.    register char **mp;
  236.  
  237.    gotorc(STATUS_ROW,0);
  238.    setvattrib(DIS_HEAD);
  239.  
  240.    mp = &m1;                           /* display cnt msg strings */
  241.    for ( ; cnt; cnt--, mp++) {
  242.       disp_str(*mp);
  243.       len += strlen(*mp);
  244.    }
  245.  
  246.    if (len < MSGLEN)                   /* blank fill msg field */
  247.       disp_rep(' ',MSGLEN-len);
  248.  
  249.    setvattrib(DIS_NORM);
  250. }
  251.  
  252. clr_msg() {    /* clear msg field on status line */
  253.  
  254.    gotorc(STATUS_ROW,0);
  255.    setvattrib(DIS_HEAD);
  256.    disp_rep(' ',MSGLEN);
  257.    setvattrib(DIS_NORM);
  258. }
  259.  
  260.  
  261. /******************************************************************************
  262.  **                         C E N T E R _ T E X T                            **
  263.  *****************************************************************************/
  264.  
  265. center_text(row,text)          /* center text in a heading line */
  266. int row;
  267. char *text;
  268. {
  269.    setvattrib(DIS_HEAD);
  270.  
  271.    disp_rep_at(' ',SCREEN_COLS,row,0);
  272.    disp_str_at(text,row,SCREEN_COLS/2 - strlen(text)/2);
  273.  
  274.    setvattrib(DIS_NORM);
  275. }
  276.